﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace TestImport.Model.DatabaseRepositories
{
    public abstract partial class DatabaseRepository
    {
        /*********/
        /* Varia */
        /*********/

        public DataTable Varia_GetData()
        {
            return defaultExecuteReaderDataTable(CommandType.Text, "SELECT variaID, maxIsbnNr FROM Varia");
        }

        public DataTable Varia_GetMaxIsbnNr()
        {
            return defaultExecuteReaderDataTable(CommandType.Text, "SELECT MAX(maxIsbnNr) AS maxIsbnNr FROM Varia");
        }

        public void Varia_SetMaxIsbnNr(int maxIsbnNr)
        {
            try
            {
                dbManager.Open();
                dbManager.CreateParameters(1);
                dbManager.AddParameters(0, "@maxIsbnNr", maxIsbnNr);
                dbManager.ExecuteNonQuery(CommandType.Text, "UPDATE Varia SET maxIsbnNr = @maxIsbnNr WHERE (variaID = 1)");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
                dbManager.Dispose();
            }
        }

    }
}
